package com.itlnn.xfhttp;


import com.itlnn.xfhttp.able.HttpListener;
import com.yolanda.nohttp.rest.OnResponseListener;
import com.yolanda.nohttp.rest.Response;

/**
 * 网络请求返回处理类
 *          此类中会处理所有的返回结果
 * @User :      xuyuqiang
 * @Date :      2016/12/27 下午2:07
 * @Version :   1.0.0
 * @ClassName : HttpResponse
 **/
public class HttpResponse <T> implements OnResponseListener<T> {

    private HttpListener<T> callBack ;

    public HttpResponse(HttpListener<T> callBack) {
        this.callBack = callBack;
    }

    @Override
    public void onStart(int what) {
        /** 请求开始 */
    }

    @Override
    public void onFinish(int what) {
        /** 请求完成 */
    }

    @Override
    public void onSucceed(int what, Response<T> response) {
        if (callBack != null){
            callBack.onSucceed(what , response);
        }
    }

    @Override
    public void onFailed(int what, Response<T> response) {
        if (callBack != null){
            callBack.onFailed(what , response);
        }
    }
}
